'use strict';
module.exports = app => {
  const { INTEGER, DATE, STRING, NOW } = app.Sequelize;
  const User = app.model.define('user', {
    user_id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    name: {
      type: STRING,
      defaultValue: '',
    },
    username: {
      type: STRING,
      defaultValue: '',
      allowNull: false,
    },
    password: {
      type: STRING,
      defaultValue: '',
      allowNull: false,
    },
    avatar: {
      type: STRING,
      defaultValue: '',
    },
    status: {
      type: INTEGER,
      defaultValue: 1,
    },
    telephone: STRING,
    last_login_ip: STRING,
    last_login_at: STRING,
    role_id: {
      type: STRING,
      defaultValue: '',
      field: 'role_id',
    },
    created_at: {
      type: DATE,
      defaultValue: NOW,
    },
  }, {
    timestamps: false,
    tableName: 'l_user',
  })

  return User;
}
